#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include<vector>
using namespace std;
int main() {
	int num;
	cin >> num;
	int poi = num;
	vector<int> v1;
	while (poi--) {
		int ret;
		cin >> ret;
		v1.push_back(ret);
	}
	if (num == 0)
	{
		cout << 0;
		return 0;
	}
	int flag = 0;
	vector<int>::iterator it1 = v1.begin();
	vector<int>::iterator it2 = v1.begin() + 1;
	while (it2 != v1.end()) {
		while ((*it2 <= *it1) && it2 != v1.end())
		{
			it2++;
			it1++;
			if ((*it2 > *it1) && it2 != v1.end())
			{
				flag++;
				it1 = it2;
				it2++;
				break;
			}
		}
		while ((*it2 >= *it1) && it2 != v1.end())
		{
			it2++;
			it1++;
			if (((*it2) < (*it1)) && it2 != v1.end())
			{
				flag++;
				it1 = it2;
				it2++;
				break;
			}
		}
	}
	if (it1 == v1.end() - 1)
		flag++;
	cout << flag;
}